/**
 * @File name: init.h
 * @Synopsis:
 * @Author: xing.dai@aliyun.com
 * @Version: 0.0.1
 * @Date: 2018-12-21 21:40
 */

#ifndef __INIT_H__
#define __INIT_H__

#define _DO_CONCAT(x, y) x ## y
#define _CONCAT(x, y) _DO_CONCAT(x, y)

typedef int (*init_call)(void);

//#pragma pack(16)
struct config_init_t{
	int (*init)(void);
	const char *name;
};
//#pragma pack()


//#define SINGLE

#ifdef SINGLE

#define _init __attribute__((used, section(".__config_init_pre_1")))
//#define DECLARE_INIT(func) init_call _fn_##func _init = func
#define DECLARE_INIT(func) \
	static struct config_init_t _fn_##func _init = {	\
		.init = func }



#else

#define CONFIG_INIT(init_name, init_func, level, data)						\
	static struct config_init_t _CONCAT(__config_init_, init_name)	\
			__attribute__((used, section(".__config_init_pre_"#level))) = {		\
			.init = init_func,											\
		}
#endif
#endif

